package com.example.idachuappone.cook;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Locale;

import org.json.JSONException;
import org.json.JSONObject;

import android.app.AlertDialog.Builder;
import android.app.Dialog;
import android.content.DialogInterface;
import android.content.DialogInterface.OnCancelListener;
import android.content.Intent;
import android.graphics.drawable.BitmapDrawable;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.view.animation.AnimationUtils;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.PopupWindow;
import android.widget.PopupWindow.OnDismissListener;
import android.widget.TextView;

import com.baidu.location.BDGeofence;
import com.baidu.location.BDLocation;
import com.baidu.location.BDLocationListener;
import com.baidu.location.LocationClient;
import com.baidu.location.LocationClientOption;
import com.baidu.location.LocationClientOption.LocationMode;
import com.example.idachuappone.R;
import com.example.idachuappone.cook.action.CookAction;
import com.example.idachuappone.cook.adapter.CookTwoAdapter;
import com.example.idachuappone.cook.dialog.DialogCookNav;
import com.example.idachuappone.cook.dialog.DialogCookNav.CallBackTags;
import com.example.idachuappone.cook.entity.Area;
import com.example.idachuappone.cook.entity.Cook;
import com.example.idachuappone.cook.entity.Set;
import com.example.idachuappone.cook.entity.Tags;
import com.example.idachuappone.cook.item.CookDetailActivity;
import com.example.idachuappone.cook.item.SearchCookListActivity;
import com.example.idachuappone.person.item.LoginActivity;
import com.example.idachuappone.promptly.item.AddAddressActivity;
import com.example.idachuappone.utils.AppShareData;
import com.example.idachuappone.utils.BitmapUtilHelper;
import com.example.idachuappone.utils.CheckUtil;
import com.example.idachuappone.utils.ComUtil;
import com.example.idachuappone.utils.Constant;
import com.example.idachuappone.utils.MainToast;
import com.example.idachuappone.utils.NetUtil;
import com.example.idachuappone.utils.PrefUtil;
import com.example.idachuappone.utils.Utils;
import com.handmark.pulltorefresh.library.PullToRefreshBase;
import com.handmark.pulltorefresh.library.PullToRefreshBase.OnRefreshListener2;
import com.handmark.pulltorefresh.library.PullToRefreshListView;
import com.lidroid.xutils.BitmapUtils;
import com.lidroid.xutils.bitmap.BitmapGlobalConfig.BitmapCacheManagementTask;
import com.lidroid.xutils.exception.HttpException;
import com.lidroid.xutils.http.ResponseInfo;
import com.lidroid.xutils.http.callback.RequestCallBack;

public class CookFragTwo extends Fragment implements OnClickListener, OnItemClickListener {
	public static Cook cook;
	private String areaid;
	private String breed;
	private String breedid;
	private Button btn_search_cook;
	private BitmapUtils bu;
	private CookAction cookAction;
	private PopupWindow dialogAre;
	private Dialog dialogLoading;
	private PopupWindow dialogSort;
	private PopupWindow dialogTags;
	private String fuJinLocation;
	private ImageView img_cook_address;
	private ImageView img_cook_sort;
	private ImageView img_cook_tags;
	private String jiaLocation;
	private List<Area> listAreas;
	private List<Tags> listTags;
	private LinearLayout ll_address_main;
	private LinearLayout ll_nav;
	private LinearLayout ll_no_data;
	private LinearLayout ll_no_network;
	private LinearLayout ll_sort;
	private LinearLayout ll_tags;
	private double locLat;
	private double locLon;
	private PullToRefreshListView lv_cook;
	public LocationClient mLocationClient;
	private CookTwoAdapter myAdapater;
	public BDLocationListener myListener;
	private int page;
	private String paramCoordinate;
	private int positionAres;
	private int positionTags;
	private Set set;
	private int sort;
	private TextView tv_cook_address;
	private TextView tv_cook_sort;
	private TextView tv_cook_tags;

	public class MyLocationListener implements BDLocationListener {
		@Override
		public void onReceiveLocation(BDLocation location) {
			CookFragTwo.this.mLocationClient.stop();
			if (location == null) {
				CookFragTwo.this.ll_no_network.setVisibility(0);
				CookFragTwo.this.dialogLoading.dismiss();
				MainToast.show(CookFragTwo.this.getActivity(), "\u65e0\u6cd5\u83b7\u53d6\u5f53\u524d\u4f4d\u7f6e", 0);
			} else if (location.getLocType() == 61 || location.getLocType() == 161) {
				CookFragTwo.this.locLat = location.getLatitude();
				CookFragTwo.this.locLon = location.getLongitude();
				PrefUtil.getInstance(CookFragTwo.this.getActivity()).setLocateTime(System.currentTimeMillis());
				CookFragTwo.this.paramCoordinate = new StringBuilder(String.valueOf(String
						.valueOf(CookFragTwo.this.locLon))).append(",").append(String.valueOf(CookFragTwo.this.locLat))
						.toString();
				CookFragTwo.this.fuJinLocation = CookFragTwo.this.paramCoordinate;
				PrefUtil.getInstance(CookFragTwo.this.getActivity()).setLocateCoor(CookFragTwo.this.paramCoordinate);
				CookFragTwo.this.getCookData();
			} else {
				CookFragTwo.this.ll_no_network.setVisibility(0);
				CookFragTwo.this.dialogLoading.dismiss();
				MainToast.show(CookFragTwo.this.getActivity(), "\u65e0\u6cd5\u83b7\u53d6\u5f53\u524d\u4f4d\u7f6e", 0);
			}
		}
	}

	public CookFragTwo() {
		this.mLocationClient = null;
		this.myListener = new MyLocationListener();
		this.sort = 3;
		this.page = 1;
	}

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		cook = new Cook();
		this.cookAction = new CookAction();
		this.bu = BitmapUtilHelper.createBitmapUtil(getActivity());
		this.dialogLoading = ComUtil.createCusProgressSmallBlackBgDialog(getActivity());
		this.dialogLoading.setOnCancelListener(new OnCancelListener() {
			@Override
			public void onCancel(DialogInterface dialog) {
				CookFragTwo.this.dialogLoading.dismiss();
			}
		});
	}

	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
		View view = inflater.inflate(R.layout.cook_two, null);
		initView(view);
		checkNet();
		return view;
	}

	@Override
	public void onResume() {
		super.onResume();
		if (AppShareData.isRefreshCityCook) {
			AppShareData.isRefreshCityCook = false;
			this.page = 1;
			this.breedid = "";
			this.areaid = "";
			this.sort = 3;
			this.tv_cook_address.setText("\u9644\u8fd1");
			this.tv_cook_tags.setText("\u83dc\u7cfb");
			this.tv_cook_sort.setText("\u8bc4\u4ef7\u6700\u597d");
			this.positionAres = 0;
			this.positionTags = 0;
			this.listAreas = null;
			this.listTags = null;
			checkNet();
		}
	}

	private void checkNet() {
		if (CheckUtil.checkNet(getActivity())) {
			initData();
		} else {
			this.ll_no_network.setVisibility(0);
		}
	}

	private void initData() {
		this.dialogLoading.show();
		NetUtil.get(getActivity(), Constant.SETS, 100, new RequestCallBack<String>() {
			@Override
			public void onSuccess(ResponseInfo<String> responseInfo) {
				try {
					JSONObject jsonObject = new JSONObject(NetUtil.unescapeUnicode(responseInfo.result));
					if (jsonObject.getInt("code") == 10000) {
						CookFragTwo.this.set = new Set();
						CookFragTwo.this.set.parseJson(jsonObject.getJSONObject("data"));
						CookFragTwo.this.initLocation();
						return;
					}
					MainToast.show(CookFragTwo.this.getActivity(), jsonObject.getString("error"), 0);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}

			@Override
			public void onFailure(HttpException arg0, String arg1) {
				CookFragTwo.this.dialogLoading.dismiss();
				CookFragTwo.this.ll_no_network.setVisibility(0);
			}
		});
	}

	private LocationClientOption setOptionMap() {
		LocationClientOption option = new LocationClientOption();
		option.setLocationMode(LocationMode.Hight_Accuracy);
		option.setCoorType(BDGeofence.COORD_TYPE_BD09LL);
		option.setScanSpan(LocationClientOption.MIN_SCAN_SPAN);
		option.setIsNeedAddress(true);
		option.setAddrType("all");
		return option;
	}

	private void initLocation() {
		this.mLocationClient = new LocationClient(getActivity());
		this.mLocationClient.registerLocationListener(this.myListener);
		this.mLocationClient.setLocOption(setOptionMap());
		if (System.currentTimeMillis() - PrefUtil.getInstance(getActivity()).getLocateTime() > 600000) {
			this.mLocationClient.start();
			return;
		}
		this.paramCoordinate = PrefUtil.getInstance(getActivity()).getLocateCoor();
		if (this.paramCoordinate == null || "".equals(this.paramCoordinate)) {
			this.mLocationClient.start();
			return;
		}
		this.fuJinLocation = this.paramCoordinate;
		getCookData();
	}

	private void getCookData() {
		this.paramCoordinate = this.paramCoordinate == null ? PrefUtil.getInstance(getActivity()).getLocateCoor()
				: this.paramCoordinate;
		NetUtil.get(getActivity(), getUrl(), 100, new RequestCallBack<String>() {
			@Override
			public void onSuccess(ResponseInfo<String> responseInfo) {
				CookFragTwo.this.ll_no_network.setVisibility(BitmapCacheManagementTask.MESSAGE_CLEAR_MEMORY_BY_KEY);
				CookFragTwo.this.dialogLoading.dismiss();
				try {
					JSONObject jsonObject = new JSONObject(NetUtil.unescapeUnicode(responseInfo.result));
					if (jsonObject.getInt("code") == 10000) {
						cook.parseJson(jsonObject.getJSONObject("data"));
						if (cook.getResults() == null || cook.getResults().size() <= 0) {
							CookFragTwo.this.lv_cook.onRefreshComplete();
							CookFragTwo.this.ll_no_data.setVisibility(0);
							return;
						}
						CookFragTwo.this.ll_no_data
								.setVisibility(BitmapCacheManagementTask.MESSAGE_CLEAR_MEMORY_BY_KEY);
						CookFragTwo.this.initAdapter();
						CookFragTwo.this.lv_cook.getRefreshableView().requestFocusFromTouch();
						CookFragTwo.this.lv_cook.getRefreshableView().setSelection(0);
						return;
					}
					MainToast.show(CookFragTwo.this.getActivity(), jsonObject.getString("error"), 0);
				} catch (JSONException e) {
					e.printStackTrace();
					MainToast.show(CookFragTwo.this.getActivity(),
							CookFragTwo.this.getResources().getString(R.string.app_error), 0);
				}
			}

			@Override
			public void onFailure(HttpException arg0, String arg1) {
				CookFragTwo.this.dialogLoading.dismiss();
				CookFragTwo.this.lv_cook.onRefreshComplete();
				CookFragTwo.this.ll_no_network.setVisibility(0);
			}
		});
	}

	private String getUrl() {
		this.breedid = this.breedid == null ? "" : this.breedid;
		return "http://www.idachu.cn/api/kitchener/search?page=" + this.page + "&tag_id=" + this.breedid + "&location="
				+ this.paramCoordinate + "&order=" + this.sort + "&area_id=" + this.areaid;
	}

	private void addData(String path) {
		NetUtil.get(getActivity(), path, 100, new RequestCallBack<String>() {
			@Override
			public void onSuccess(ResponseInfo<String> responseInfo) {
				CookFragTwo.this.dialogLoading.dismiss();
				try {
					JSONObject jsonObject = new JSONObject(NetUtil.unescapeUnicode(responseInfo.result));
					if (jsonObject.getInt("code") == 10000) {
						Cook cook1 = new Cook();
						cook1.parseJson(jsonObject.getJSONObject("data"));
						if (cook1.getResults() == null || cook1.getResults().size() <= 0) {
							CookFragTwo.this.lv_cook.onRefreshComplete();
							MainToast.show(CookFragTwo.this.getActivity(),
									"\u6ca1\u6709\u66f4\u591a\u6570\u636e\u4e86", 0);
							return;
						}
						cook.getResults().addAll(cook1.getResults());
						CookFragTwo.this.initAdapter();
					} else if (jsonObject.getInt("code") == 300) {
						MainToast.show(CookFragTwo.this.getActivity(), jsonObject.getString("error"), 0);
					}
				} catch (JSONException e) {
					e.printStackTrace();
					MainToast.show(CookFragTwo.this.getActivity(),
							CookFragTwo.this.getResources().getString(R.string.netFail), 0);
				}
			}

			@Override
			public void onFailure(HttpException arg0, String arg1) {
				CookFragTwo.this.lv_cook.onRefreshComplete();
				CookFragTwo cookFragTwo = CookFragTwo.this;
				cookFragTwo.page = cookFragTwo.page - 1;
				MainToast.show(CookFragTwo.this.getActivity(),
						CookFragTwo.this.getResources().getString(R.string.netFail), 0);
			}
		});
	}

	private void initView(View view) {
		this.ll_no_network = (LinearLayout) view.findViewById(R.id.ll_no_network);
		this.ll_no_network.setOnClickListener(this);
		this.ll_no_data = (LinearLayout) view.findViewById(R.id.ll_no_data);
		this.btn_search_cook = (Button) view.findViewById(R.id.btn_search_cook);
		this.btn_search_cook.setOnClickListener(this);
		this.lv_cook = (PullToRefreshListView) view.findViewById(R.id.lv_cook);
		this.ll_nav = (LinearLayout) view.findViewById(R.id.ll_nav);
		this.ll_address_main = (LinearLayout) view.findViewById(R.id.ll_address_main);
		this.ll_address_main.setOnClickListener(this);
		this.tv_cook_address = (TextView) view.findViewById(R.id.tv_cook_address);
		this.img_cook_address = (ImageView) view.findViewById(R.id.img_cook_address);
		this.ll_tags = (LinearLayout) view.findViewById(R.id.ll_tags);
		this.ll_tags.setOnClickListener(this);
		this.tv_cook_tags = (TextView) view.findViewById(R.id.tv_cook_tags);
		this.img_cook_tags = (ImageView) view.findViewById(R.id.img_cook_tags);
		this.ll_sort = (LinearLayout) view.findViewById(R.id.ll_sort);
		this.ll_sort.setOnClickListener(this);
		this.tv_cook_sort = (TextView) view.findViewById(R.id.tv_cook_sort);
		this.img_cook_sort = (ImageView) view.findViewById(R.id.img_cook_sort);
		this.myAdapater = new CookTwoAdapter(getActivity(), this.bu);
		this.lv_cook.setAdapter(this.myAdapater);
		this.lv_cook.getLoadingLayoutProxy(false, true).setPullLabel("\u52a0\u8f7d\u66f4\u591a");
		this.lv_cook.getLoadingLayoutProxy(false, true).setRefreshingLabel("\u6b63\u5728\u52a0\u8f7d...");
		this.lv_cook.getLoadingLayoutProxy(false, true).setReleaseLabel("\u677e\u5f00\u52a0\u8f7d...");
		this.lv_cook.setOnItemClickListener(this);
		this.lv_cook.setOnRefreshListener(new OnRefreshListener2<ListView>() {
			@Override
			public void onPullDownToRefresh(PullToRefreshBase<ListView> refreshView) {
				refreshView.getLoadingLayoutProxy(true, false).setLastUpdatedLabel(
						"\u4e0a\u6b21\u5237\u65b0:"
								+ new SimpleDateFormat("MM-dd HH:mm", Locale.CHINESE).format(new Date()));
				CookFragTwo.this.page = 1;
				CookFragTwo.this.getCookData();
			}

			@Override
			public void onPullUpToRefresh(PullToRefreshBase<ListView> pullToRefreshBase) {
				CookFragTwo cookFragTwo = CookFragTwo.this;
				cookFragTwo.page = cookFragTwo.page + 1;
				CookFragTwo.this.addData(CookFragTwo.this.getUrl());
			}
		});
	}

	@Override
	public void onItemClick(AdapterView<?> adapterView, View arg1, int position, long arg3) {
		String result = this.cookAction.isCookService(cook.getResults().get(position - 1));
		if (result == null) {
			Intent intent = new Intent(getActivity(), CookDetailActivity.class);
			intent.putExtra("id", cook.getResults().get(position - 1).getId());
			startActivity(intent);
			return;
		}
		MainToast.show(getActivity(), result, 0);
	}

	@Override
	public void onClick(View v) {
		switch (v.getId()) {
		case R.id.ll_no_network /* 2131165232 */:
			checkNet();
		case R.id.ll_address_main /* 2131165284 */:
			closeDialog();
			if (this.set != null && this.set.getArea() != null) {
				if (this.listAreas == null) {
					this.listAreas = new ArrayList();
					Area area0 = new Area("", "\u9644\u8fd1");
					Area area1 = new Area("", "\u5bb6");
					this.listAreas.add(area0);
					this.listAreas.add(area1);
					this.listAreas.addAll(this.set.getArea());
				}
				this.img_cook_address.setImageResource(R.drawable.icon_cook_nav_on);
				this.dialogAre = new DialogCookNav().showAddressList(getActivity(),
						Utils.getScreenWidth(getActivity()), this.listAreas, this.positionAres, this.img_cook_address,
						new CallBackTags() {
							@Override
							public void onDialogDismiss() {
								CookFragTwo.this.dialogAre.dismiss();
							}

							@Override
							public void onClick(int index) {
								CookFragTwo.this.img_cook_address.setImageResource(R.drawable.icon_cook_nav_off);
								CookFragTwo.this.dialogAre.dismiss();
								CookFragTwo.this.page = 1;
								CookFragTwo.this.dialogLoading.show();
								if (index == 0) {
									CookFragTwo.this.positionAres = index;
									CookFragTwo.this.areaid = CookFragTwo.this.listAreas.get(
											CookFragTwo.this.positionAres).getId();
									CookFragTwo.this.tv_cook_address.setText(CookFragTwo.this.listAreas.get(
											CookFragTwo.this.positionAres).getName());
									CookFragTwo.this.paramCoordinate = CookFragTwo.this.fuJinLocation;
								} else if (index != 1) {
									CookFragTwo.this.positionAres = index;
									CookFragTwo.this.areaid = CookFragTwo.this.listAreas.get(
											CookFragTwo.this.positionAres).getId();
									CookFragTwo.this.tv_cook_address.setText(CookFragTwo.this.listAreas.get(
											CookFragTwo.this.positionAres).getName());
									CookFragTwo.this.paramCoordinate = CookFragTwo.this.fuJinLocation;
								} else if (PrefUtil.getInstance(CookFragTwo.this.getActivity()).getUID() == null
										|| PrefUtil.getInstance(CookFragTwo.this.getActivity()).getUID().trim()
												.length() <= 0) {
									MainToast.show(CookFragTwo.this.getActivity(), "\u8bf7\u5148\u767b\u5f55", 0);
									CookFragTwo.this.startActivityForResult(new Intent(CookFragTwo.this.getActivity(),
											LoginActivity.class), 111);
								} else if (PrefUtil.getInstance(CookFragTwo.this.getActivity()).getXiaoQu() == null
										|| PrefUtil.getInstance(CookFragTwo.this.getActivity()).getXiaoQu().length() <= 0) {
									new Builder(CookFragTwo.this.getActivity())
											.setMessage("\u4eb2\uff01\u8bf7\u5148\u6dfb\u52a0\u5bb6\u7684\u5730\u5740~")
											.setPositiveButton("\u53bb\u6dfb\u52a0",
													new DialogInterface.OnClickListener() {
														@Override
														public void onClick(DialogInterface dialog, int which) {
															Intent intent = new Intent(CookFragTwo.this.getActivity(),
																	AddAddressActivity.class);
															intent.putExtra("isNoData", true);
															CookFragTwo.this.startActivityForResult(intent, 222);
														}
													})
											.setNegativeButton("\u53d6\u6d88", new DialogInterface.OnClickListener() {
												@Override
												public void onClick(DialogInterface dialog, int which) {
												}
											}).create().show();
								} else {
									CookFragTwo.this.positionAres = index;
									CookFragTwo.this.areaid = CookFragTwo.this.listAreas.get(
											CookFragTwo.this.positionAres).getId();
									CookFragTwo.this.tv_cook_address.setText(CookFragTwo.this.listAreas.get(
											CookFragTwo.this.positionAres).getName());
									CookFragTwo.this.paramCoordinate = PrefUtil.getInstance(
											CookFragTwo.this.getActivity()).getFimallyLocateCoor();
								}
								CookFragTwo.this.getCookData();
							}
						});
				this.dialogAre.showAsDropDown(this.ll_nav, 0, 0);
			}
		case R.id.ll_tags /* 2131165287 */:
			closeDialog();
			if (this.set != null && this.set.getTag() != null) {
				if (this.listTags == null) {
					this.listTags = new ArrayList();
					this.listTags.add(new Tags("", "\u5168\u90e8", ""));
					this.listTags.addAll(this.set.getTag());
				}
				this.img_cook_tags.setImageResource(R.drawable.icon_cook_nav_on);
				this.dialogTags = new DialogCookNav().showTagsList(getActivity(), Utils.getScreenWidth(getActivity()),
						this.listTags, this.positionTags, this.img_cook_tags, new CallBackTags() {
							@Override
							public void onDialogDismiss() {
								CookFragTwo.this.dialogTags.dismiss();
							}

							@Override
							public void onClick(int index) {
								CookFragTwo.this.img_cook_tags.setImageResource(R.drawable.icon_cook_nav_off);
								CookFragTwo.this.dialogTags.dismiss();
								CookFragTwo.this.positionTags = index;
								CookFragTwo.this.breed = CookFragTwo.this.listTags.get(CookFragTwo.this.positionTags)
										.getName();
								if (CookFragTwo.this.positionTags == 0) {
									CookFragTwo.this.breed = "";
								}
								CookFragTwo.this.breedid = CookFragTwo.this.listTags.get(CookFragTwo.this.positionTags)
										.getId();
								CookFragTwo.this.tv_cook_tags.setText(CookFragTwo.this.listTags.get(
										CookFragTwo.this.positionTags).getName());
								CookFragTwo.this.dialogTags.dismiss();
								CookFragTwo.this.page = 1;
								CookFragTwo.this.dialogLoading.show();
								CookFragTwo.this.getCookData();
							}
						});
				this.dialogTags.showAsDropDown(this.ll_nav, 0, 0);
			}
		case R.id.ll_sort /* 2131165290 */:
			closeDialog();
			this.img_cook_sort.setImageResource(R.drawable.icon_cook_nav_on);
			showSortList(this.ll_nav);
		case R.id.btn_search_cook /* 2131165429 */:
			closeDialog();
			Intent intent = new Intent(getActivity(), SearchCookListActivity.class);
			intent.putExtra("paramCoordinate", this.fuJinLocation);
			startActivity(intent);
		case R.id.btn_comment_good /* 2131165439 */:
			this.tv_cook_sort.setText("\u8bc4\u4ef7\u6700\u597d");
			this.dialogSort.dismiss();
			this.page = 1;
			this.sort = 3;
			this.dialogLoading.show();
			getCookData();
		case R.id.btn_promp_num /* 2131165440 */:
			this.tv_cook_sort.setText("\u9884\u8ba2\u6b21\u6570");
			this.dialogSort.dismiss();
			this.page = 1;
			this.sort = 4;
			this.dialogLoading.show();
			getCookData();
		default:
		}
	}

	public void closeDialog() {
		if (this.dialogTags != null) {
			this.dialogTags.dismiss();
		}
		if (this.dialogSort != null) {
			this.dialogSort.dismiss();
		}
		if (this.dialogAre != null) {
			this.dialogAre.dismiss();
		}
	}

	@Override
	public void onActivityResult(int requestCode, int resultCode, Intent data) {
		super.onActivityResult(requestCode, resultCode, data);
		if (requestCode == 111) {
			getActivity();
			if (resultCode == -1) {
				if (PrefUtil.getInstance(getActivity()).getXiaoQu() == null
						|| PrefUtil.getInstance(getActivity()).getXiaoQu().length() <= 0) {
					new Builder(getActivity())
							.setMessage("\u4eb2\uff01\u8bf7\u5148\u6dfb\u52a0\u5bb6\u7684\u5730\u5740~")
							.setPositiveButton("\u53bb\u6dfb\u52a0", new DialogInterface.OnClickListener() {
								@Override
								public void onClick(DialogInterface dialog, int which) {
									Intent intent = new Intent(CookFragTwo.this.getActivity(), AddAddressActivity.class);
									intent.putExtra("isNoData", true);
									CookFragTwo.this.startActivityForResult(intent, 222);
								}
							}).setNegativeButton("\u53d6\u6d88", new DialogInterface.OnClickListener() {
								@Override
								public void onClick(DialogInterface dialog, int which) {
								}
							}).create().show();
				} else {
					this.positionAres = 1;
					this.areaid = this.listAreas.get(1).getId();
					this.tv_cook_address.setText(this.listAreas.get(1).getName());
					this.paramCoordinate = PrefUtil.getInstance(getActivity()).getFimallyLocateCoor();
					getCookData();
				}
			}
			if (requestCode == 222) {
				getActivity();
				if (resultCode == -1) {
					this.positionAres = 1;
					this.areaid = this.listAreas.get(1).getId();
					this.tv_cook_address.setText(this.listAreas.get(1).getName());
					this.paramCoordinate = PrefUtil.getInstance(getActivity()).getFimallyLocateCoor();
					getCookData();
				}
			}
		}
	}

	private void showSortList(LinearLayout ll) {
		View popupWindow = LinearLayout.inflate(getActivity(), R.layout.dialog_cook_sort, null);
		this.dialogSort = new PopupWindow(popupWindow);
		this.dialogSort.setOnDismissListener(new OnDismissListener() {
			@Override
			public void onDismiss() {
				CookFragTwo.this.img_cook_sort.setImageResource(R.drawable.icon_cook_nav_off);
			}
		});
		((LinearLayout) popupWindow.findViewById(R.id.ll_dismiss)).setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				CookFragTwo.this.dialogSort.dismiss();
			}
		});
		LinearLayout ll_main = (LinearLayout) popupWindow.findViewById(R.id.ll_main);
		Button btn_comment_good = (Button) popupWindow.findViewById(R.id.btn_comment_good);
		btn_comment_good.setOnClickListener(this);
		Button btn_promp_num = (Button) popupWindow.findViewById(R.id.btn_promp_num);
		btn_promp_num.setOnClickListener(this);
		if (this.sort == 3) {
			btn_comment_good.setTextColor(getResources().getColor(R.color.white));
			btn_promp_num.setTextColor(getResources().getColor(R.color.color_two_lable_txt));
			btn_comment_good.setBackgroundResource(R.drawable.img_round);
			btn_promp_num.setBackgroundResource(R.drawable.rbtn_cook_sort);
		} else if (this.sort == 4) {
			btn_comment_good.setTextColor(getResources().getColor(R.color.color_two_lable_txt));
			btn_promp_num.setTextColor(getResources().getColor(R.color.white));
			btn_comment_good.setBackgroundResource(R.drawable.rbtn_cook_sort);
			btn_promp_num.setBackgroundResource(R.drawable.img_round);
		}
		ll_main.startAnimation(AnimationUtils.loadAnimation(getActivity(), R.anim.dialog_cook_nav_in));
		this.dialogSort.setWidth(-1);
		this.dialogSort.setHeight(-1);
		this.dialogSort.setBackgroundDrawable(new BitmapDrawable());
		this.dialogSort.setOutsideTouchable(false);
		this.dialogSort.setFocusable(true);
		this.dialogSort.showAsDropDown(this.ll_nav, 0, 0);
	}

	private void initAdapter() {
		this.myAdapater.setBreed(this.breed);
		this.myAdapater.setLocation(this.paramCoordinate);
		this.myAdapater.setList(cook.getResults());
		this.myAdapater.notifyDataSetChanged();
		this.lv_cook.onRefreshComplete();
	}
}
